package com.huike.refreslistview;

import android.os.Bundle;
import android.os.Handler;
import android.widget.ArrayAdapter;

import java.util.ArrayList;

import androidx.appcompat.app.AppCompatActivity;

/**
 * 下拉动画二 样式不同
 */
public class MainActivity extends AppCompatActivity {

    private RefreshListView lv_main;
    private ArrayList<String> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        list = new ArrayList<>();
        for (int i = 0; i <30; i++) {
            list.add("a" + i);
        }
        final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, list);
        lv_main.setAdapter(adapter);

        lv_main.setonRefreshListener(new RefreshListView.onRefreshListener() {
            @Override
            public void onRefresh() {

                new Handler().postDelayed(new Runnable() {//模拟延迟
                    @Override
                    public void run() {

                        for (int i = 0; i <30; i++) {
                            list.add("a" + i);
                        }

                        adapter.notifyDataSetChanged();

                        //回调关闭头部方法
                        lv_main.setComplenterListener();

                    }
                },3000);




            }
        });



    }

    private void initView() {
        lv_main = (RefreshListView) findViewById(R.id.lv_main);
    }


}
